package com.koron.css2.clientCenter.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.koron.css2.ServerInterface;
import com.koron.css2.clientCenter.bean.UserStopListBean;
import com.koron.css2.clientCenter.mapper.StopUserMapper;
import com.koron.css2.clientCenter.queryBean.StopUserQueryBean;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import com.koron.util.Tools;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.List;

/**
 * 停用初始化列表
 * 
 * @author 甄玉晴
 *
 */
public class StopUserList implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		try {
			StopUserQueryBean queryBean = JsonUtils.objectToPojo(req.getData(), StopUserQueryBean.class);
			StopUserMapper mapper = factory.getMapper(StopUserMapper.class);
			PageHelper.startPage(queryBean.getPage(), queryBean.getPageCount());
			//获取列表
			List<UserStopListBean> list = mapper.userStopList(queryBean);
			//转换状态字段
			for (UserStopListBean bean : list) {
				bean.setProcessState(Tools.transProcessStatus(bean.getProcessState()));
			}
			@SuppressWarnings("rawtypes")
			MessageBean<PageInfo> info = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "查询成功", PageInfo.class);
			info.setData(new PageInfo<>(list));
			return info;
		} catch (Exception e) {
			logger.error("停用列表查询失败" + e.getMessage(), e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "查询失败", null);
		}
	}

}
